<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>FastAPI Message</title>
</head>
<body>
    <h1>获取:</h1>
    <p id="message">Loading...</p>

    <script>
        // 发送 GET 请求到后端
        fetch("http://127.0.0.1:8000/")
            .then(response => response.json()) // 将响应解析为 JSON
            .then(data => {
                // 将 message 显示在页面上
                document.getElementById("message").textContent = data.message;
            })
            .catch(error => {
                console.error("Error fetching message:", error);
                document.getElementById("message").textContent = "Error fetching message.";
            });
    </script>
</body>
</html>